Repository navigation
perf: reduce nested worker message serialization overhead - #200
Merged
Merged
Conversation
steipete
marked this pull request as ready for review
October 24, 2026 22:26
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nested session metadata makes
Worker.postMessage()miss the flat-object fast path. The general serializer then atomizes value strings, after already paying for cross-thread copies of the rejected primitive prefix. This change uses content-keyed string pooling for in-process messages and checks flat-object eligibility before allocating those copies. Successful flat objects keep the existing isolation path and reserve their exact property count.Storage and cross-process callers retain canonical Identifier encoding. The pool remains per serialization, with no retained cache, wire-version change, or change to message scheduling.
Paired benchmark
Three separate quiet, on-demand c7i.4xlarge instances (16 vCPUs), Node 26.12.1, with the same verified release-profile candidate executable. Ten interleaved triples per instance; 25,000 warmup and 250,000 measured operations in 1,000-message batches. Only the synchronous send loop is timed; acknowledgments and checksum validation are outside it. Baseline:
openclaw-v1.4.4-20261019-ef37c31de3-webkit-a2976f02e6.The candidate reduces median paired sender cost by 30.6–34.3% and is near Node's median on each instance. This is a sender-latency result, not an equivalent end-to-end throughput claim: first-instance batch elapsed medians were baseline 1,069.93 ms, candidate 1,040.65 ms, Node 889.06 ms.
All thirty interleaved triples (ns/op):
bench/postMessage/postMessage-session-entry.mjspreserves the payload, counts, and sender-timer boundary for reproduction:Regression guard
Thirty paired samples per cell, ten on each of the three instances. The decision statistic is the median of all thirty paired ratios, with a fixed ceiling of 1.03. Timed JavaScript, payloads and payload-specific operation counts are unchanged.
Supplemental flat-object pooled ratios: empty 0.989340; 16-key flat object 1.018603; 24 flattened leaves 0.991893 (30 pairs each).
Validation
structured-clone-fastpath,workers/structured-clone, andworkers/message-port-pipe; zero failures. Three existing tests are debug/ASAN-gated and do not run in release builds; no skips were added or changed.264b8a6d24e5007b98d1a3c16e1174eabd24bbd5. The CI merge commit has the identical Git tree to that head. Formatting, source lints and JavaScript lint also passed.